#ifndef GAME_H
#define GAME_H

#include "Player.h"
#include "AI.h"
#include "TCPNetwork.h"
#include "dxManager.h"
#include "DirectSound.h"

class Game
{
private:
	char ** board;
	short x, y, xOffset, yOffset, prevX, prevY;
	unsigned char direction;
	Player * p1;
	Player * p2;
	Player * currPlayer;
	Player * nextPlayer;
	bool skippedTurn;

	TCPNetwork tcpNetwork;

	// sets if the player is hosting a game, joining a game or Playing by himself
	int gameStatus;

	// Holds the X/Y for the menu cursour....
	int MenuInputX;
	int MenuInputY;

	void countPieces();

	//// Graphics 
	//IDirect3DTexture9 * BlackTileTex;
	//IDirect3DTexture9 * WhiteTileTex;
	//IDirect3DTexture9 * GreenTileTex;
	//D3DXVECTOR3 TileCenter;

public:
	

	void printTitleScreen();

	bool gameOver;

	Game();

	void setupPlayers();
	void setupHost();
	void setupJoin(char *);

	void sendDate();

	void setupBoard();
	void drawBoard(dxManager *);
	void handleInput(char input);
	void update();
	bool legalMove(Player * p);
	bool legalMove(Player * p, int row, int col);
	Player* getP1() {return p1;}
	Player* getP2() {return p2;}
	Player* getCurrPlayer() {return currPlayer;}
	Player* getNextPlayer() {return nextPlayer;}
	
	int getGameStatus() { return gameStatus;}
	bool anyLegalMovesLeft();

	void setGameStatus(int i) { gameStatus = i; }

	// accessoooorrr
	char getBoard(int y, int x) { return board[y][x];}

	int getX() {return x;}
	int getY() {return y;}

	int getMenuX() { return MenuInputX;}
	int getMenuY() { return MenuInputY;}

	void increaseMenuY() {++MenuInputY;}
	void decreaseMenuY() {--MenuInputY;}

	void setMenuY(int y) {MenuInputY = y;}

	void changeGameStatusHost(){ gameStatus = 5; }
	void changeGameStatusJOIN(){ gameStatus = 6; }
	void changeGameStatusSIngle() {gameStatus = 3;}


};

#endif